﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace PanoramaApp
{
    public partial class PanoramaPage1 : PhoneApplicationPage
    {
        public PanoramaPage1()
        {
            InitializeComponent();
        }

        private void sliderChangeValue(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            string value = (string)((Slider)sender).Tag;
            TextBlock textBlock = (TextBlock)FindName(value);
            textBlock.Text = Convert.ToString((int)((Slider)sender).Value);

            SolidColorBrush clr = new SolidColorBrush();
            clr.Color = Color.FromArgb(255, (byte)redSlider.Value, (byte)greenSlider.Value, (byte)blueSlider.Value);
            app.Background = clr;
        }

        private void loadBackground(object sender, RoutedEventArgs e)
        {
            SolidColorBrush clr = (SolidColorBrush)((Button)sender).Background;
            if (clr != null)
            {
                greenSlider.Value = clr.Color.G;
                blueSlider.Value = clr.Color.B;
                redSlider.Value = clr.Color.R;
                app.Background = ((Button)sender).Background;
            } else {
                MessageBox.Show("Mantenga el botón oprimido para guardar la combinación de colores actual");
            }
        }

        private void saveBackground(object sender, GestureEventArgs e)
        {
            SolidColorBrush clr = new SolidColorBrush();
            clr.Color = Color.FromArgb(255, (byte)redSlider.Value, (byte)greenSlider.Value, (byte)blueSlider.Value);
            ((Button)sender).Background = clr;
        }
    }
}